<%--
  Created by IntelliJ IDEA.
  User: haojianlei
  Date: 2018-12-04
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <!-- 原始地址：//webapi.amap.com/ui/1.0/ui/misc/PathSimplifier/examples/simple-demo.html -->
    <base href="//webapi.amap.com/ui/1.0/ui/misc/PathSimplifier/examples/" />
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>简单路径</title>
    <style>
        html,
        body,
        #container {
            width: 100%;
            height: 100%;
            margin: 0px;
        }
    </style>
</head>

<body>
<div id="container"></div>

<script type="text/javascript" src='https://webapi.amap.com/maps?v=1.4.11&key=30556745e1796cbe4f69a621a8bc58bf'></script>
<!-- UI组件库 1.0 -->
<script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>

<Script language="javascript">
    function getRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
</script>
<script>
    $(function () {
        var getParams = getRequest("mmsi");
        alert(getParams);
    })
</script>

<script type="text/javascript">

    var map = new AMap.Map('container', {
        zoom: 4
    });

    AMapUI.load(['ui/misc/PathSimplifier', 'lib/$'], function(PathSimplifier, $) {

        if (!PathSimplifier.supportCanvas) {
            alert('当前环境不支持 Canvas！');
            return;
        }

        var pathSimplifierIns = new PathSimplifier({
            zIndex: 100,
            //autoSetFitView:false,
            map: map, //所属的地图实例

            getPath: function(pathData, pathIndex) {
                var data = [];
                for(var i =0;i<pathData.path.length;i++){
                    // console.log(pathData.path[i].lnglat)
                    data.push(pathData.path[i].lnglat)
                }
                return data;
            },
            getHoverTitle: function(pathData, pathIndex, pointIndex) {
                //设置展示title
                if (pointIndex >= 0) {
                    //point
                    // console.log(pathData.path[pointIndex].name)
                    return pathData.path[pointIndex].name;
                }

                return pathData.name + '，点数量' + pathData.path.length;
            },
            renderOptions: {

                renderAllPointsIfNumberBelow: 100 //绘制路线节点，如不需要可设置为-1
            }
        });

        window.pathSimplifierIns = pathSimplifierIns;

        //设置数据
        pathSimplifierIns.setData([{
            name: '路线0',
            path:  [{
                name: "点a",
                lnglat: [116.405289, 39.904987]
            }, {
                name: "点b",
                lnglat: [113.964458, 40.54664]
            }, {
                name: "点c",
                lnglat: [111.47836, 41.135964]
            }, {
                name: "点d",
                lnglat: [108.949297, 41.670904]
            }, {
                name: "点e",
                lnglat: [106.380111, 42.149509]
            }, {
                name: "点f",
                lnglat: [103.774185, 42.56996]
            }, {
                name: "点g",
                lnglat: [101.135432, 42.930601]
            }, {
                name: "点h",
                lnglat: [98.46826, 43.229964]
            }, {
                name: "点i",
                lnglat: [95.777529, 43.466798]
            }, {
                name: "点j",
                lnglat: [93.068486, 43.64009]
            }, {
                name: "点k",
                lnglat: [90.34669, 43.749086]
            }, {
                name: "点l",
                lnglat: [36.61792, 43.793308]
            }]
        }]);

        //对第一条线路（即索引 0）创建一个巡航器
        var navg1 = pathSimplifierIns.createPathNavigator(0, {
            loop: true, //循环播放
            speed: 1000000 //巡航速度，单位千米/小时
        });

        navg1.start();
    });
</script>


</body>

</html>
